#pragma once

#include <json/json.h>
#include <Logicnode.h>
#include <QFile>
#include <queue>
#include <mutex>
#include <cassert>
#include <condition_variable>
#include <thread>
#include <memory>
#include <unordered_map>
#include <functional>

constexpr int MAX_QUEUE_SIZE = 20480;

constexpr auto FILE_PATH = "../res/file_download";

class LogicWork
{
public:
	LogicWork();
	void start();
	void stop();
	bool postTask(std::shared_ptr<LogicNode> logicNode);
	~LogicWork();
private:
	void handler(std::shared_ptr<LogicNode> logicNode);

private:
	bool bStop_;
	std::mutex logicLock_;
	std::condition_variable logicCond_;
	std::queue<std::shared_ptr<LogicNode>> logicQueue_;
	std::shared_ptr<std::thread> workThread_;
};
